home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / cursor.pqs / cursor.pas
Encoding:
Pascal/Delphi Source File  |  1985-07-26  |  8.3 KB  |  181 lines

  1.     (*********************************************************************)
  2.     (* Note:  In order to use this file as an include file  in  a  Turbo *) 
  3.     (* Pascal  program  you  would  add  this line to your main program: *) 
  4.     (* {$I CURSOR.INC}                                                   *)
  5.     (* (or  whatever  name  you  choose  for  the include file) prior to *) 
  6.     (* calling any of the functions or procedures.                       *)
  7.     (*********************************************************************)
  8.  
  9. (*Include file CURSOR.INC;     {Version 1.0}
  10.      {This file contains  cursor  related  ROM  BIOS  8088  software  interrupt 
  11.       functions  and  procedures  for  inclusion  in other programs and are 
  12.       written in Turbo Pascal,  version 3.01,  MS-DOS/PC-DOS implementation for 
  13.       the  IBM  PC.  All  parameters pass to and from the BIOS routines through 
  14.       the 8088 registers.  The interface between Pascal and the 8088 is through 
  15.       the variable 'Result' which is of type 'registers'.  The type 'registers' 
  16.       and the variable 'Result' must be declared as globals in the main program 
  17.       as  well as the other types listed below.  These functions and procedures 
  18.       were compiled by George E.  Noel, Route 2 Box 75, Crookston, MN, 56716 in 
  19.       March of 1985 and are public domain.} 
  20.  
  21. type     {global type}
  22.      registers = record
  23.                   AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags: integer;
  24.                  end;
  25.  
  26. var     {global variable}
  27.      Result: registers;*)
  28.  
  29. (****************************************************************************)
  30. (*                       DISPLAY I/O SUPPORT INTERRUPTS                     *)
  31. (****************************************************************************)
  32.  
  33. procedure SetCursorType (StartLine, EndLine: byte);
  34.      {This procedure sets the start and end lines for the cursor.  The  passed 
  35.       values must not exceed 31 to avoid erratic blinking or no cursor at all. 
  36.       If  the  start line is after the end line,  no cursor will be displayed. 
  37.       The maximun scan line for the monochrome is 13. If the start line is set
  38.       to 14 or higher, no cursor will be displayed.} 
  39.  
  40.      const
  41.           InterruptNumber = $10;                     {BIOS interrupt VIDEO_IO}
  42.  
  43.      var
  44.           AH, AL, CH, CL: byte;   {accumulator register - high byte, low byte}
  45.                                         {count register - high byte, low byte}
  46.  
  47.      begin
  48.           with Result do         {using the global variable of type regesters}
  49.           begin
  50.                AH := 1;      {indicate the desired operation in the high byte}
  51.                AX := AH shl 8 + AL;  {then place high byte in the accumulator}
  52.                CH := StartLine;    {set high counter to start line for cursor}
  53.                CL := EndLine;         {set low counter to end line for cursor}
  54.                CX := CH shl 8 + CL;     {then place both bytes in the counter}
  55.                intr(InterruptNumber,Result);     {pre-declared turbo function}
  56.           end;
  57.      end;     {end of procedure SetCursorType}
  58.  
  59. (****************************************************************************)
  60.  
  61. function CursorType: integer;
  62.      {This function gets the current cursor mode and returns it as an  integer 
  63.       in  the  same  format  as the CX register.  The CH register contains the 
  64.       start of the cursor line and the CL register contains the end.} 
  65.  
  66.      const
  67.           InterruptNumber = $10;                  {BIOS interrupt KEYBOARD_IO}
  68.  
  69.      var
  70.           AH,AL: byte;            {accumulator register - high byte, low byte}
  71.  
  72.      begin
  73.           with Result do         {using the global variable of type regesters}
  74.           begin
  75.                AH := 3;      {indicate the desired operation in the high byte}
  76.                AX := AH shl 8 + AL;  {then place high byte in the accumulator}
  77.                intr(InterruptNumber,Result);     {pre-declared turbo function}
  78.                CursorType := CX;         {assign value to function designator}
  79.           end;
  80.      end;     {end of function CursorType}
  81.  
  82. (****************************************************************************)
  83.  
  84. procedure SetCursorPosition (Row, Column, Page: byte);
  85.      {This procedure positions the cursor on the passed page number  (0-7  for 
  86.       modes  0  & 1,  0-3 for modes 2 & 3.) at the passed row and column.  The 
  87.       page number must be zero for the graphics modes.  The upper left  corner 
  88.       is (row,column) - (0,0).} 
  89.  
  90.      const
  91.           InterruptNumber = $10;                     {BIOS interrupt VIDEO_IO}
  92.  
  93.      var
  94.           AH, AL,                 {accumulator register - high byte, low byte}
  95.           DH, DL, BH, BL: byte;          {date register - high byte, low byte}
  96.                                          {base register - high byte, low byte}
  97.  
  98.      begin
  99.           with Result do         {using the global variable of type regesters}
  100.           begin
  101.                AH := 2;      {indicate the desired operation in the high byte}
  102.                AX := AH shl 8 + AL;  {then place high byte in the accumulator}
  103.                DH := Row;       {set the high data register to the cursor row}
  104.                DL := Column;  {set the low data register to the cursor column}
  105.                DX := DH shl 8 + DL;    {then place both bytes in the register}
  106.                BH := Page;     {set the high base register to the page number}
  107.                BX := BH shl 8 + BL;     {then place high byte in the register}
  108.                intr(InterruptNumber,Result);     {pre-declared turbo function}
  109.           end;
  110.      end;     {end of procedure SetCursorPosition}
  111.  
  112. (****************************************************************************)
  113.  
  114. function CursorPosition (Page: byte): integer;
  115.      {This  function  returns  the  position  of the cursor on the passed page 
  116.       number. (0-7 for modes 0 & 1, 0-3 for modes 2 & 3.  The page number must 
  117.       be  zero  for  the  graphics  modes.)  The  value returned is an integer 
  118.       ranging from 0 (the upper left hand corner of the screen) to  1999  (the
  119.       lower  right  corner).  The row can be calculated by row = value div 80. 
  120.       The column can be calculated by column = value mod 80.  The  upper  left 
  121.       corner would then be (0,0).}
  122.  
  123.      const
  124.           InterruptNumber = $10;                     {BIOS interrupt VIDEO_IO}
  125.  
  126.      var
  127.           AH, AL, BH, BL: byte;   {accumulator register - high byte, low byte}
  128.                                          {base register - high byte, low byte}
  129.  
  130.      begin
  131.           with Result do         {using the global variable of type regesters}
  132.           begin
  133.                AH := 3;      {indicate the desired operation in the high byte}
  134.                AX := AH shl 8 + AL;  {then place high byte in the accumulator}
  135.                BH := Page;     {set the high base register to the page number}
  136.                BX := BH shl 8 + BL;     {then place high byte in the register}
  137.                intr(InterruptNumber,Result);     {pre-declared turbo function}
  138.                CursorPosition := ((DX shr 8 * 80) + (DX mod 256));
  139.                    {cursor position as row number times 80 plus column number}
  140.           end;
  141.      end;     {end of procedure SetCursorPosition}
  142.  
  143. (****************************************************************************)
  144.  
  145. procedure CursorOff;
  146.      {This procedure uses the procedure SetCursorType to turn the cursor off on 
  147.       a monochrome display.} 
  148.  
  149.      begin
  150.           SetCursorType (15,0);
  151.  
  152.      end;
  153.  
  154. (****************************************************************************)
  155.  
  156. procedure CursorOn;
  157.      {This procedure uses the procedure SetCursorType to set the cursor to its
  158.      maximun height on a monochrome display.}
  159.  
  160.      begin
  161.           SetCursorType (0,13);
  162.  
  163.      end;
  164.  
  165. (****************************************************************************)
  166.  
  167. procedure CursorNorm;
  168.      {This procedure uses the procedure SetCursorType to set the cursor to its
  169.      normal appearance on a monochrome display.}
  170.  
  171.      begin
  172.           SetCursorType (12,13);
  173.  
  174.      end;
  175.  
  176. (****************************************************************************)
  177.                         {end of include file CURSOR.INC}
  178.  
  179.  
  180.